package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

const (
	ERROR   = 500
	SUCCESS = 200
)

func Ok(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": SUCCESS,
		"msg":  "操作成功",
	})
}
func OkMeg(msg string, c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": SUCCESS,
		"msg":  msg,
	})
}

func OkData(data interface{}, msg string, c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": SUCCESS,
		"data": data,
		"msg":  msg,
	})
}

func Fail(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": ERROR,
		"msg":  "操作失败",
	})
}
func FailMsg(msg string, c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": ERROR,
		"msg":  msg,
	})
}
func FailData(data interface{}, msg string, c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"code": ERROR,
		"data": data,
		"msg":  msg,
	})
}
